<?php
ob_start();
include '/var/www/html/new/d/common/header.html';
include '/var/www/html/new/d/common/left.html';
include '/var/www/html/new/d/class/Member.php';
include '/var/www/html/new/d/class/abc/PFTCore777.class.php';
include '/var/www/html/new/d/common/area.inc.php';
$html = ob_get_contents();
ob_end_clean();
use pft\Member\MemberAccount;
$memberSID = $_SESSION['sid'];
// 异步获取指定
if(isset($_REQUEST['act']) && $_REQUEST['act']=='ticket' && isset($_REQUEST['lid'])){
	
	$lid  = $_REQUEST['lid'] + 0;
	$m    = new Member($s, $memberSID);
	
	$salePros = $m->salePros($lid);
	
	$ac = $GLOBALS['_ac'];
	$pw = $GLOBALS['_pw'];
	$s  = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
	
	// 获取已配置项
	$tidaid_data = array();
	$sql = "select id,tid_aid from uu_qunar_use where fid=$memberSID";
	$GLOBALS['le']->query($sql);	
	while($row=$GLOBALS['le']->fetch_assoc()) $tidaid_data[$row['tid_aid']] = $row['id']; 
	
	$lists = array();
	$today = date('Y-m-d');
	$filter = array();// 过滤重复，多个供应商，只取一个 20150901 小彭
	foreach($salePros as $row){
		if(in_array($row['pid'], $filter)) continue;
		// 获取零售价和结算价
		$pStorage = PFTCore777::Dynamic_Price_And_Storage($s, $_SESSION['saccount'], $row['pid'], $row['sapply_did'], $today, 2, 0);
		if($pStorage['js']['p']==-1) continue;
		$filter[] = $row['pid'];
		
		$list = array(
			'lid' => $row['lid'], 'pid' => $row['pid'], 'tid' => $row['tid'], 'aid' => $_SESSION['sid'],
			'ttitle' => $row['ttitle'], 'uprice' => $pStorage['ls']['p'], 'jsprice'=> $pStorage['js']['p'], 'bind_a' => 0, 'bid_a'=>0,
			'bind_b' => 0, 'bid_b' => 0
		);
		$qunaer_key  = $row['tid'].'_'.$_SESSION['sid'];
		$meituan_key = $_SESSION['sid'].'|'.$row['lid'].'|'.$row['tid'];
		if(isset($tidaid_data[$qunaer_key])){
			$list['bind_a'] = 1;
			$list['bid_a']  = $tidaid_data[$qunaer_key];
		}
		
		if(isset($tidaid_data[$meituan_key])){
			$list['bind_b'] = 1;
			$list['bid_b']  = $tidaid_data[$meituan_key];
		}
		
		$lists[] = $list;
		
	}
	exit(json_encode(array('status'=>'success','lists'=>$lists)));
	
}



echo $html;
include '/var/www/html/new/d/tpl/qunaer_new/qunaer.html';
include '/var/www/html/new/d/common/footer.html';